package com.bj.boot.actuator.health;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author shkstart
 * @create 2021-09-22 18:38
 */
@Component
public class MyComHealthIndicator extends AbstractHealthIndicator {


    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        Map<String,Object> map=new HashMap<>();
        if(1==2){
            builder.status(Status.UP);
            map.put("count",1);
            map.put("ms",100);
        }else{
            builder.status(Status.DOWN);
            map.put("err","连接超时");
            map.put("ms",3000);
        }

        builder.withDetail("code",100).withDetails(map);

    }
}
